package com.gemme.gemme.view;

import android.app.Activity;
import android.content.Context;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.gemme.gemme.R;
import com.gemme.gemme.util.DpUtil;
import com.gemme.gemme.util.ShapeUtil;

public class NoDataView extends RelativeLayout {
    private Context context;
    public NoDataView(Context context) {
        this(context,null);
    }

    public NoDataView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public NoDataView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
        initView();
    }

    TextView tv_refresh;
    ProgressBar progress_bar;
    private void initView() {
        LayoutInflater.from(context).inflate(R.layout.no_data_view,this);

        tv_refresh = findViewById(R.id.tv_refresh);

        tv_refresh.setBackground(ShapeUtil.setCornBgStrok(DpUtil.dp2px((Activity) context,14),"#ffffffff",
                DpUtil.dp2px((Activity) context,1),"#FFAAAAAA"));
//        setBackground(ShapeUtil.getCornBg(DpUtil.dp2px((Activity) context,4),"#ff9d2c2f"));

        progress_bar = findViewById(R.id.progress_bar);
    }

    public void setClick(OnClickListener onClickListener) {
        tv_refresh.setOnClickListener(onClickListener);
        progress_bar.setVisibility(VISIBLE);

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                progress_bar.setVisibility(GONE);
            }
        }, 1000);

    }


}
